import { useAppConfig } from '@vben/hooks';

const { tileServerUrl } = useAppConfig(import.meta.env, import.meta.env.PROD);

const mapUrls = {
  tianditu: {
    vectorMap: {
      online: [
        'http://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
        'http://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
      ],
      offline: [
        'http://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
        'http://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
      ],
    },
    imageMap: {
      online: [
        'http://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
        'http://t0.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
      ],
      offline: [
        `${tileServerUrl}/tile?x={x}&y={y}&z={z}`,
        'http://t0.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
      ],
    },
    terrainMap: {
      online: [
        'http://t0.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
        'http://t0.tianditu.gov.cn/cta_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cta&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
      ],
      offline: [
        'http://t0.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
        'http://t0.tianditu.gov.cn/cta_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cta&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=8c31891d983e2cc64d93f877dc0cec86',
      ],
    },
  },
  mapbox: {
    vectorMap: {
      offline: ['http://172.21.213.250:9000/tiles/mapbox/{z}/{x}/{y}.pbf'],
    },
  },
};
export const mapSources = {
  vectorMap: [
    {
      type: 'raster',
      tiles: [mapUrls.tianditu.vectorMap.offline[0]],
      tileSize: 256,
    },
    {
      type: 'raster',
      tiles: [mapUrls.tianditu.vectorMap.offline[1]],
      tileSize: 256,
    },
  ],
  imageMap: [
    {
      type: 'raster',
      tiles: [mapUrls.tianditu.imageMap.offline[0]],
      tileSize: 256,
    },
    // {
    //   type: 'raster',
    //   tiles: [mapUrls.tianditu.imageMap.offline[1]],
    //   tileSize: 256,
    // },
  ],
  terrainMap: [
    {
      type: 'raster',
      tiles: [mapUrls.tianditu.terrainMap.offline[0]],
      tileSize: 256,
    },
    {
      type: 'raster',
      tiles: [mapUrls.tianditu.terrainMap.offline[1]],
      tileSize: 256,
    },
  ],
  vectorMapTiles: [
    {
      type: 'vector',
      tiles: ['http://172.21.213.250:9000/tiles/mapbox/{z}/{x}/{y}.pbf'],
    },
  ],
};
